package com.emergency.engine.controller;

import com.emergency.base.domain.Plan;
import com.emergency.base.domain.Scenar;
import com.emergency.common.util.JwtUtil;
import com.emergency.engine.dao.ScenarPartDao;
import com.emergency.engine.domain.ScenarPart;
import com.emergency.engine.service.SchemeService;
import com.emergency.common.entity.Result;
import com.emergency.common.entity.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.security.acl.LastOwnerException;
import java.util.List;

/**
 * Created by lijie on 2019/10/17.
 */
@RestController
@RequestMapping("/scheme")
@Api(value="方案计划推演类",description = "指挥系统提供多套方案，推演系统根据想定文件和方案推演出最优方案")
public class SchemeController {

    @Autowired
    private SchemeService schemeService;

    @ApiOperation(value = "方案推演",notes="按文件对多套方案进行推演照想定,返回给方案推演打分结果")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Scenar", value = "想定文件", required = true, paramType = "query", dataType = "File"),
            @ApiImplicitParam(name = "planList", value = "方案集合", required = true, paramType = "query", dataType = "List")
    })
    @RequestMapping(value = "/deduction",method = RequestMethod.POST)
    public Result deduction( @RequestParam(value ="scenarId")Long scenarId,@RequestBody List<Plan> planList){
        List results = schemeService.deductionPlan(scenarId,planList);

        return new Result(true, StatusCode.OK,  "推演成功", results);
    }


    @ApiOperation(value = "推演片段查询接口" ,  notes="推演片段查询接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "scenarId", value = "想定文件片段", required = true, paramType = "query"),
    })
    @RequestMapping(value = "/scenar/part",method = RequestMethod.GET)
    public Result deductionProgress(Long scenarId, Integer type){

        List<ScenarPart> scenarPart = schemeService.getProgressPart(scenarId,type);

        return new Result(true, StatusCode.OK,  "查询成功", scenarPart);
    }

    @ApiOperation(value = "推演片段写入" ,  notes="第三方接口，写入实时数据，通过系统转换成ScenarPart，提供态势展示")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "scenarPart", value = "实时数据片段", required = true, paramType = "query"),
    })
    @RequestMapping(value = "/third/part/add",method = RequestMethod.POST)
    public Result deductionProgress(String scenarPart){



        return new Result(true, StatusCode.OK,  "查询成功", scenarPart);
    }
}
